﻿using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Mod_Report_frm_PrintPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string strReportUrl = this.Page.Request.Params["ReportUrl"].ToString();//报表文件

            ClsReportDAL cls_report = new ClsReportDAL();
            DataSet dst = cls_report.GetReportSetInfo();

            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                string strPath = dst.Tables[0].Rows[0][1].ToString().Trim();//应用服务路径
                int intWidth = Int32.Parse(dst.Tables[0].Rows[0][2].ToString().Trim());//报表宽度
                int intHeight = Int32.Parse(dst.Tables[0].Rows[0][3].ToString().Trim());//报表高度

                this.lblReport.Text = "<script language=javascript>var report = new runqianReport(\"" + intWidth + "\", \"" + intHeight + "\"); report.setServerURL(\"" + strPath + "\");</script>";

                StringBuilder strApp = new StringBuilder();
                strApp.Append("<script language=javascript>");
                strApp.Append("report.init();");
                strApp.Append("report.setFile('" + strReportUrl + "');");

                string strParam = this.Page.Request.Params["Params"];

                if (strParam != null && strParam.Trim() != "")
                {
                    string[] patams = strParam.Split(new char[] { '|' });

                    if (patams[0].ToString().Trim() == "1")
                    {
                        strApp.Append("report.putParam('area_no', '" + patams[1].ToString().Trim() + "');");
                        strApp.Append("report.putParam('beginDate', '" + patams[2].ToString().Trim() + "');");
                        strApp.Append("report.putParam('endDate', '" + patams[3].ToString().Trim() + "');");
                        strApp.Append("report.putParam('area_name', '" + patams[4].ToString().Trim() + "');");
                        //this.Page.Response.Write(strReportUrl + "|" + patams[1].ToString().Trim() + "|" + patams[2].ToString().Trim() + "|" + patams[3].ToString().Trim() + "|" + patams[4].ToString().Trim());
                    }
                }

                strApp.Append("report.display();");
                strApp.Append("</script>");

                this.lblJs.Text = strApp.ToString();
            }
            else
            {
                this.lblJs.Text = "<script>alert('获取报表服务配置信息失败！');</script>";
            }
        }
        else
        {
            this.lblJs.Text = "";
        }
    }
}
